package com.sixteengroup.personnelms.service.mesadmin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sixteengroup.personnelms.bean.Article;
import com.sixteengroup.personnelms.bean.ComInfo;
import com.sixteengroup.personnelms.bean.Recruit;
import com.sixteengroup.personnelms.dao.mesadmin.MessageMegDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author 月下赶路人
 * @Date 2021-08-13 19:02
 * @function 公司信息管理查询_service
 */
@Service
@Transactional
public class MessageService {
    @Autowired
    MessageMegDao messageMegDao;

    public List<String> getDeptName() {
        List<String> list = messageMegDao.getDeptName();
        return list;
    }

    public ComInfo getComInfo() {
        return messageMegDao.selectById(1);
    }

    public void saveComInfo(ComInfo comInfo) {
        messageMegDao.updateById(comInfo);
    }

    public PageInfo<Article> getArticle(Article queryInfo) {
        PageHelper.startPage(queryInfo.getPageNum(), queryInfo.getPageSize());
        PageInfo<Article> pageInfo = new PageInfo<>(messageMegDao.getArticle());
        return pageInfo;
    }

    public Article getArticleInfo(String id) {
        return messageMegDao.getArticleInfo(id);
    }

    public void saveArticle(Article article) {
        messageMegDao.saveArticle(article);
    }

    public void deleteArticle(String id) {
        String[] arr = id.split(",");
        messageMegDao.deleteArticle(arr);
    }

    public void updateArticle(Article article) {
        messageMegDao.updateArticle(article);
    }

    public PageInfo<Recruit> getRecruit(Recruit queryInfo) {
        PageHelper.startPage(queryInfo.getPageNum(), queryInfo.getPageSize());
        PageInfo<Recruit> pageInfo = new PageInfo<>(messageMegDao.getRecruit());
        return pageInfo;
    }

    public Recruit getRecruitInfo(String id) {
        Recruit recruitInfo = messageMegDao.getRecruitInfo(id);
        recruitInfo.setDeptName(getDeptName());
        return recruitInfo;
    }

    public void saveRecruitInfo(Recruit recruit) {
        messageMegDao.saveRecruitInfo(recruit);
    }

    public void deleteRecruit(String id) {
        String[] arr = id.split(",");
        messageMegDao.deleteRecruit(arr);
    }

    public void updateRecruit(Recruit recruit) {
        messageMegDao.updateRecruit(recruit);
    }

    public void sendRecruit(String deptName, Integer id) {
        messageMegDao.sendRecruit(deptName,id);
    }

    public String judge(Integer id) {
        return messageMegDao.judge(id);
    }
}
